const WXAPI = require('apifm-wxapi')
Page({
  data: {
    footer_img: wx.getStorageSync('footer_img'),
    my_img1: wx.getStorageSync('my_img1'),
    companyLatitude: wx.getStorageSync('companyLatitude'), // 公司经度  https://lbs.qq.com/getPoint/#Z
    companyLongitude: wx.getStorageSync('companyLongitude'), // 公司纬度
    companyAddress: wx.getStorageSync('companyAddress'), // 公司详细地址
    companyName: wx.getStorageSync('companyName'), // 公司名称

  },
  onLoad: function (options) {
    const that = this;
    that.setData({
      footer_img: wx.getStorageSync('footer_img'),
      my_img1: wx.getStorageSync('my_img1'),
      companyLatitude: wx.getStorageSync('companyLatitude'), 
      companyLongitude: wx.getStorageSync('companyLongitude'), 
      companyAddress: wx.getStorageSync('companyAddress'), 
      companyName: wx.getStorageSync('companyName'), 
    });
  },
  onShow: function () {

  },





  //跳转到列表页面
  toList: function (t) {
    var a = t.currentTarget.dataset.categoryid;
    wx.navigateTo({
      url: "/pages/a1_list/index?categoryId=" + a
    })
  },

  //跳转到详情页面
  toPost: function (t) {
    var a = t.currentTarget.dataset.postid;
    wx.navigateTo({
      url: "/pages/a1_post/index?categoryId=" + a
    })
  },


  //跳转到地址
  map: function () {
    console.log("companyLatitude",this.data.companyLatitude);
    wx.openLocation({
      latitude: this.data.companyLatitude * 1,
      longitude: this.data.companyLongitude * 1,
      name: this.data.companyName,
      address: this.data.companyAddress,
      scale: 18, // 地图缩放级别，默认为18
      success: function (res) {
        console.log('打开地图成功')
      },
      fail: function (err) {
        console.error('打开地图失败：', err)
      }
    });
  },

  //拨打电话
  callPhone() {
    wx.makePhoneCall({
      phoneNumber: wx.getStorageSync('phone')
    })
  },

    //拨打电话
    callPhone2() {
      wx.makePhoneCall({
        phoneNumber: wx.getStorageSync('phone2')
      })
    },
  
  // 打开视频号主页
  toVideo() {
    wx.openChannelsUserProfile({
      finderUserName: wx.getStorageSync('sphid'),
    });
  },


  onShareAppMessage() { },
  onShareTimeline() { },
})